//
//  ViewController.m
//  TextFieldTest
//
//  Created by iD Student on 7/8/13.
//  Copyright (c) 2013 jasonkurtzman. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

bool isRed = false;
bool isBlue = false;
bool isYellow = false;
bool isGreen = false;
bool isBlack = true;

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.field.delegate = self;
	// Do any additional setup after loading the view, typically from a nib.
}

-(IBAction)redPress:(id)sender
{
    isRed = true;
    isBlue = false;
    isYellow = false;
    isGreen = false;
    isBlack = false;
}

-(IBAction)bluePress:(id)sender
{
    isRed = false;
    isBlue = true;
    isYellow = false;
    isGreen = false;
    isBlack = false;
}

-(IBAction)greenPress:(id)sender
{
    isRed = false;
    isBlue = false;
    isYellow = false;
    isGreen = true;
    isBlack = false;
}

-(IBAction)yellowPress:(id)sender
{
    isRed = false;
    isBlue = false;
    isYellow = true;
    isGreen = false;
    isBlack = false;
}

-(IBAction)blackPress:(id)sender
{
    isRed = false;
    isBlue = false;
    isYellow = false;
    isGreen = false;
    isBlack = true;
}

-(IBAction)buttonClick:(id)sender
{
    NSString *text = _field.text;
    if(isRed)
    {
        _label.textColor = [UIColor redColor];
    }
    else if(isBlue)
    {
        _label.textColor = [UIColor blueColor];
    }
    else if(isYellow)
    {
        _label.textColor = [UIColor yellowColor];
    }
    else if(isGreen)
    {
        _label.textColor = [UIColor greenColor];
    }
    else if(isBlack)
    {
        _label.textColor = [UIColor blackColor];
    }
    
    _label.text = text;
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return NO;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
